package com.sun.alen.stagetwo.ElectricCarExtendsCar;

/**
 * ElectricCar类表示一辆电动车，继承自Car类
 * 添加了电池相关属性和电动车特有的行驶逻辑
 */
public class ElectricCar extends  Car{
    //为ElectricCar添加电池相关属性(电池容量、剩余电量)
    private int batteryCapacity;
    private int remainingCharge;
    
    /**
     * ElectricCar类的构造函数
     * @param brand 电动车品牌
     * @param model 电动车型号
     * @param batteryCapacity 电池容量
     * @param remainingCharge 剩余电量
     */
    public ElectricCar(String brand, String model,  int batteryCapacity, int remainingCharge) {
        super(brand, model);
        this.batteryCapacity = batteryCapacity;
        this.remainingCharge = remainingCharge;
    }
    
    /**
     * 重写run方法，首先调用super.run执行父类的运行逻辑，增加电池使用逻辑和电量显示
     */
    @Override
    public void run() {
        // 调用父类的run方法，执行基本的行驶逻辑
        super.run();
        System.out.println("电池容量为"+batteryCapacity+" 剩余电量：" + remainingCharge);
        remainingCharge -= 10;
        if (remainingCharge <= 0) {
            System.out.println("电量不足，请充电");
        }
    }
}